﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using StockManagement.ViewModels;

namespace StockManagement.Views
{
    /// <summary>
    /// Interaktionslogik für MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        MaterialPageViewModel _materialPageVM;
        ProductPageViewModel _productPageVM;

        public MainWindow()
        {
            InitializeComponent();            
        }

        private void tabControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            switch (tabControl.SelectedIndex)
            {
                case 0:
                    if (_materialPageVM == null)
                        _materialPageVM = new MaterialPageViewModel();
                    materialsPage.DataContext = _materialPageVM;
                    break;
                case 1:
                    if (_productPageVM == null)
                        _productPageVM = new ProductPageViewModel(_materialPageVM.MaterialCollection);
                    productsPage.DataContext = _productPageVM;
                    break;
                default:
                    break;
            }
        }
    }
}
